package pais.www.stat;

import java.io.PrintWriter;
import java.util.StringTokenizer;

public class PrintSys {
  public static void printSys(PrintWriter toClient) {
  }

  public static void printSysMem(PrintWriter toClient) {
    // Get current size of heap in bytes
    long heapSizeKB = Runtime.getRuntime().totalMemory() >> 10;

    // Get maximum size of heap in bytes. The heap cannot grow beyond this size.
    // Any attempt will result in an OutOfMemoryException.
    long heapMaxSizeKB = Runtime.getRuntime().maxMemory() >> 10;

    // Get amount of free memory within the heap in bytes. This size will increase
    // after garbage collection and decrease as new objects are created.
    long heapFreeSizeKB = Runtime.getRuntime().freeMemory() >> 10;

    // e.g. { Free: 100KB( 3% ) / Curr: 20000KB ( Max : 40000KB) }
    toClient.print( "{ Free:" );
    toClient.print( heapFreeSizeKB );
    toClient.print( "KB (" );
    toClient.print( heapFreeSizeKB * 100 / heapSizeKB );
    toClient.print( "%))/Curr:" );
    toClient.print( heapSizeKB );
    toClient.print( "KB ( Max: ");
    toClient.print( heapMaxSizeKB );
    toClient.println( "KB ) }");	    
  }
}
